<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="../../../src/css/common/reset.css">

    <style>

    </style>
</head>
<body>



<script>

    var ajaxLoad = {
        //请求参数
        page: 1,
        //再次发送请求
        interval: true,
        //结构所要插入的容器
        context: '.content-box',
        //状态
        status: '',

        request: function () {
            var _this = this;
            //没有数据
            if (!this.page || !this.interval) {return;}
            $.ajax({
                type: 'get',
                data: {
                    p: _this.page,
                    status:_this.status
                },
                url: '/customer/myorder.html?t='+Date.parse(new Date()),
                beforeSend: function () {
                    _this.interval = false;
                    $('.load').removeClass('hidden');
                },
                success: function (res) {
                    _this.callback(res);
                },
                complete:function(){
                    $('.load').addClass('hidden');
                    _this.interval = true;
                },
                error: function (res) {
                    console.log(res)
                }
            });
        },
        callback:function(res){
            var data = res.data;
            if(!data || data.length < 1){
                this.page = null;
                return;
            }
        }
    }

    ajaxLoad.request();
    //菜单滚动异步处理
    $(".list-content").on("scroll",function(){
        var top = $(this).scrollTop();
        var scrollHeight = $(this)[0].scrollHeight;
        var docHeight = $(this).height();
        if(top+docHeight >= scrollHeight){
            ajaxLoad.request()
        }
    });

</script>

</body>
</html>












